﻿{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/select.js}"></script>
<script type="text/javascript">
function edit_sourcing_info(obj) {
	var row = obj.parentNode.parentNode;
	var tds = row.getElementsByTagName('td');
	$('#sourcing_info').val(tds[1].innerHTML);
	$('#fabric_info').val(tds[2].innerHTML);
	$('#fabric_shop_id').val(tds[3].getElementsByTagName('input')[0].value);
	if (tds[3].innerText) {
		if (tds[3].innerText != '') {
			$('#fabric_shop_name').val(tds[3].innerText);
		}
	} else {
		if (tds[3].textContent != '') {
			$('#fabric_shop_name').val(tds[3].textContent);
		}
	}
	$('#submit_sourcing_info').attr({'style':'display:'});
	$('#submit_sourcing_info').val('更新采购内容');
	$('#cancel_edit_sour_info').remove();
	$('#submit_sourcing_info').parent().append('<input type="button" class="btn-2" id="cancel_edit_sour_info" value="{$lang.cancel}" name="cancel_edit_sour_info" onclick="cancel_edit_sourcing_info()" style="margin-left:1em;" />');
	$('#item_id').val(tds[0].getElementsByTagName('input')[0].value);
	if (Number(tds[4].getElementsByTagName('input')[0].value) >= 2) {
		$('#sourcing_info').attr('readonly', true);
		$('#sourcing_info').attr('onfocus', 'this.blur();');
	}
}

function cancel_edit_sourcing_info() {
	$('#cancel_edit_sour_info').remove();
	$('#item_id').remove();
	$('#submit_sourcing_info').val('添加采购内容');
	$('#sourcing_info').val('');
	$('#fabric_info').val('');
	$('#fabric_shop_name').val('{$lang.select_pls}');
	$('#fabric_shop_id').val(0);
	$('#sourcing_info').attr('readonly', false);
	$('#sourcing_info').attr('onfocus', null);
}

function show_item(name) {
	if ($("tr[name='" + name + "']:eq(0)").css('display') == 'none') {
		$("tr[name='" + name + "']").show();
	} else {
		$("tr[name='" + name + "']").hide();
	}
	return false;
}

function confirm_update() {
	var factory_back_date = $.trim($('#factory_back_date').val());
	var send_sample_date = $.trim($('#send_sample_date').val());
	var msg = '';
	if (factory_back_date != '') {
		msg = '工厂返板日期';
	}
	if (send_sample_date != '') {
		msg += msg == '' ? '寄板日期' : '和寄板日期';
	}
	if (msg == '') {
		return true;
	} else {
		return confirm('您确定要更新' + msg + '吗？一旦确认更新就不能再次更新' + msg + '。');
	}
}
</script>
<style type="text/css">
.btn-2{margin-bottom:5px;}
</style>
<body>
<div class="sub-body">
      
  <div class="tab-frame">
  	<h3 class="tab-title-1">{$lang.sample_more_info}</h3>
        <div class="tab-title-1"><span>{$lang.base_info}</span><a name="base_info"></a></div>
		<form method="post" action="{url app=sample&act=edit&id=$smarty.get.id}">
    <table cellspacing="0" cellpadding="0" class="tab-display">
      <tr>
        <th>{$lang.arrival_date}：</th>
        <td class="tab-align-l">{$sample.arrival_date|date:Y-m-d}</td>
        <th>{$lang.sample_sn}：</th>
        <td class="tab-align-l" colspan="3">
          {$sample.sample_sn}</td>
      </tr>
      <tr>
        <th width="70">{$lang.brand_name}：</th>
        <td width="300" class="tab-align-l">{$sample.brand_name}</td>
        <th width="70">{$lang.buyer_name}：</th>
        <td width="300" class="tab-align-l">{$sample.buyer_name}</td>
        <th width="70">{$lang.merchandiser}：</th>
        <td class="tab-align-l">{$sample.user_name}</td>
      </tr>
      <tr>
        <th>{$lang.ref_sample_style}：</th>
        <td class="tab-align-l">{$lang.ref_sample_styles.$sample.ref_sample_style}</td>
        <th>{$lang.style_name}：</th>
        <td class="tab-align-l" colspan="3">
          <select name="style_id">
            <option value="0">{$lang.select_pls}</option>
			<!--{foreach from=$style_list item=style}-->
            <option value="{$style.style_id}" {if $sample.style_id == $style.style_id}selected{/if}>{$style.style_name|escape}</option>
			<!--{/foreach}-->
          </select>       </td>
        <!--<th>{$lang.fabric_name}：</th>
        <td class="tab-align-l"><select name="fabric_id">
			<option value="0">{$lang.select_pls}</option>
			<!--{foreach from=$fabric_list item=fabric}-->
			<option value="{$fabric.fabric_id}" {if $fabric.fabric_id == $sample.fabric_id}selected{/if}>{$fabric.fabric_name|escape}</option>
			<!--{/foreach}-->
		</select></td>-->
      </tr>
	  <!--<tr>
	  	<th>{$lang.feature_name}：</th>
	  	<td class="tab-align-l"><select name="feature_id">
			<option value="0">{$lang.select_pls}</option>
			<!--{foreach from=$feature_list item=feature}-->
			<option value="{$feature.feature_id}" {if $feature.feature_id == $sample.feature_id}selected{/if}>{$feature.feature_name|escape}</option>
			<!--{/foreach}-->
		</select></td>
	  	<th>{$lang.special_name}：</th>
	  	<td colspan="3" class="tab-align-l">
          <select name="special_id">
            <option value="0">{$lang.select_pls}</option>
			<!--{foreach from=$special_list item=special}-->
            <option value="{$special.special_id}" {if $sample.special_id == $special.special_id}selected{/if}>{$special.special_name|escape}</option>
			<!--{/foreach}-->
          </select></td>
	  </tr>-->
      <tr>
        <th>{$lang.front_pic}：</th>
        <td class="tab-align-l"><img src="{$sample.front_pic}" id="front_pic_show" width="220" height="264" /><input type="hidden" name="front_pic" id="front_pic" value="" onChange="document.getElementById('front_pic_show').src=this.value;" /></td>
        <th>{$lang.other_pic}：</th>
        <td class="tab-align-l"><img src="{$sample.other_pic}" id="other_pic_show" width="220" height="264" /><input type="hidden" name="other_pic" id="other_pic" value="" onChange="document.getElementById('other_pic_show').src=this.value;" /></td>
        <td class="tab-align-l"><input type="button" id="upload_pics" class="btn-3" value="{$lang.update_pics}" onClick="block({$sample.sample_id})"/></td>
		<td align="right" valign="bottom"><input type="submit" name="base_info" class="btn-2" value="{$lang.update}" {if $sample.confirm_date}onclick="alert('{$lang.sample_confirmed_can_not_update}');return false;"{/if}/></td>
      </tr>
    </table>
	</form>
  </div>
<br/><br/>
  <div class="tab-frame">
    <div class="tab-title-1"><span>{$lang.sourcing_infom}</span><a name="sourcing_info"></a></div>
	<table cellspacing="0" cellpadding="0" class="tab-add" id="tab-color6" style="border-bottom:none;">
	<form method="post" action="{url app=sample&act=edit&id=$smarty.get.id}" id="sourcing_info_form">
      <tr>
        <th width="80">{$lang.sourcing_info}：</th>
        <td class="tab-align-l">
          <textarea name="sourcing_info" id="sourcing_info" cols="56" rows="5"></textarea></td>
	  	<th width="80">{$lang.fabric_info}：</th>
		<td class="tab-align-l"><textarea name="fabric_info" id="fabric_info" cols="56" rows="5"></textarea></td>
      </tr>
	  <tr>
	  </tr>
      <tr>
        <th>{$lang.fabric_shop_name}：</th>
        <td class="tab-align-l" colspan="2">
		<div class="select-input">
			<input type="text" id="fabric_shop_name" class="input-2" type="text" style="width:360px;" onfocus="show_select('fabric_shop_name', 'select_txt');" onblur="hide_select('fabric_shop_name', 'fabric_shop_id', 'select_txt');" onkeyup="input_select(this.value, 'fabric_shop_id', event);" value="{$lang.select_pls}" /> <input type="hidden" name="fabric_shop_id" id="fabric_shop_id" value="0" />
			<div class="select-txt" id="select_txt" style="display:none;">
				<ul>
					<!--{foreach from=$fabricshop_list item=fabricshop}-->
					<li onMouseOver="over_select(this, 'over');" onMouseOut="out_select(this);" onMouseDown="down_select(this, 'fabric_shop_name', 'fabric_shop_id', {$fabricshop.fabric_shop_id});">{$fabricshop.fabric_shop_name}</li>
					<!--{/foreach}-->
				</ul>
			</div>
        <input type="button" class="btn-2" value="{$lang.add}" onClick="AjaxAddFabricShop();" />
		</div></td>
		<td align="middle"><input type="hidden" name="item_id" id="item_id" value="0" /><input type="hidden" name="list_id" value="{$sample.new_sourcing.list_id}" /><input name="sourcing_infom" id="submit_sourcing_info" type="submit" class="btn-2" value="添加采购内容" /></td>
      </tr>
	  </form>
	</table>
    <table cellspacing="0" cellpadding="0" class="tab-add" id="tab-color3" style="border-top:none;">
	  <!--{if !$sample.sourcing.list_sn}-->
	  <form method="post" action="{url app=sample&act=edit&id=$smarty.get.id}" id="submit_sourcing_form">
      <tr>
        <td height="40" colspan="2" bgcolor="#E2EAF0"><input type="button" class="btn-2" value="{$lang.count_sourcing_task}" onClick="CountSourcingTask();" /></td>
        <th colspan="4">{$lang.sourcing_assistant}：
          <select name="sourcing_assistant_id">
            <option value="0">{$lang.select_pls}</option>
			<!--{foreach from=$sour_list item=sour}-->
            <option value="{$sour.user_id}">{$sour.user_name}</option>
			<!--{/foreach}-->
          </select><input name="submit_sourcing" type="submit" class="btn-2" value="{$lang.submit_sourcing}" style="margin-left:2em;" /></th>
      </tr>
	  </form>
	  <!--{else}-->
	  <tr>
	  	<th colspan="2" width="320">{$lang.list_sn}：{$sample.sourcing.list_sn}</th>
		<th>{$lang.sourcing_assistant}：{$sample.sourcing.user_name}</th>
		<th colspan="2">{$lang.status}：{$lang.statuies.$sample.sourcing.status}</th>
		<td bgcolor="#E2EAF0"></td>
	  </tr>
	  <!--{/if}-->
      <tr>
        <th width="50">{$lang.No}</th>
        <th width="260">{$lang.sourcing_info}</th>
        <th width="260">{$lang.fabric_info}</th>
        <th width="260">{$lang.fabric_shop_name}</th>
        <th width="80">{$lang.status}</th>
        <th>{$lang.handle}</th>
      </tr>
	  <!--{foreach from=$sample.sourcing.item item=sour_item name=si}-->
	  <tr>
        <td>{$smarty.foreach.si.iteration}<input type="hidden" value="{$sour_item.item_id}" /></td>
        <td>{$sour_item.sourcing_info}</td>
        <td>{$sour_item.fabric_info}</td>
        <td>{$sour_item.fabric_shop_name}<input type="hidden" value="{$sour_item.fabric_shop_id}" /></td>
        <td>{$lang.sourcing_status.$sour_item.status}<input type="hidden" value="{$sour_item.status}" /></td>
        <td>
		<!--{if $sour_item.status == 0}--><input type="button" class="btn-s-2" value="{$lang.delete}" onClick="if(confirm('{$lang.confirm_delete_sourcing_item}')){location.href='{url app=sample&act=del&id=$sour_item.item_id}'}" /><!--{/if}-->
		<!--{if $sour_item.status != 2 && $sour_item.status != 4}--><input type="button" class="btn-s-1" value="{$lang.modify}" onClick="edit_sourcing_info(this);" /><!--{/if}-->
        <!--{if $sour_item.status == 3}--><input type="button" class="btn-s-6" value="{$lang.confirm}" onClick="if (confirm('{$lang.confirm_sourcing_item}')){location.href='{url app=sample&act=confirm&id=$sour_item.item_id}'}" /><!--{/if}--></td>
	  </tr>
	  <!--{/foreach}-->
      <tr>
        <th>{$lang.enclosure}：</th>
        <td id="sourcing_files" class="tab-align-l">
		<!--{foreach from=$sample.sourcing.files item=file}-->
		<a href="download.php?id={$file.file_id}">{$file.file_name}</a><a class="pic_del" href="{url app=comupload&act=delete&id=$file.file_id}" onClick="return confirm('{$lang.confirm_del_file}')" title="{$lang.delete}">&nbsp;</a><!--{if !$smarty.foreach.last}--><br /><!--{/if}-->
		<!--{/foreach}-->
		</td>
        <td class="tab-align-l" colspan="4"><input type="button" class="btn-3" value="{$lang.upload_enclosure}" onClick="upload_docs({$belongs_sourcing_list}, {$sample.sourcing.list_id});" /></td>
      </tr>
    </table>

  </div><br/><br/>
  <div class="tab-frame">
    <div class="tab-title-1"><span>{$lang.factory_info}</span></div>
    <table cellspacing="0" cellpadding="0" class="tab-add" id="tab-color4">
	<form method="post" action="{url app=sample&act=edit&id=$smarty.get.id}" id="assign_factory_form">
      <tr>
        <th width="100">{$lang.assign_factory}：</th>
        <td class="tab-align-l" width="300"><!--{if $sample.status > 4}-->{$sample.factory_name|escape}<!--{else}--><select name="factory_id">
          <option value="0">{$lang.select_pls}</option>
		  <!--{foreach from=$factory_list item=factory}-->
          <option value="{$factory.factory_id}" {if $sample.factory_id == $factory.factory_id}selected{/if}>{$factory.factory_name} | {$factory.type_name}</option>
		  <!--{/foreach}-->
        </select><!--{/if}--></td>
        <th width="100">{$lang.to_factory_date}：</th>
        <td width="150" class="tab-align-l">
		<!--{if $sample.status > 4}-->{$sample.to_factory_date|date:Y-m-d}<!--{else}--><input type="text" name="to_factory_date" class="input-1"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$sample.to_factory_date|date:Y-m-d}" /><!--{/if}--></td>
        <td class="tab-align-l"><!--{if $sample.status < 5}--><input name="assign_factory" type="submit" class="btn-2" value="{$lang.assign}" onClick="{if $sample.status > 4}alert('已经分配工厂，不需再次分配');return false;{else}return confirm('请确认工厂及送工厂日期，一旦确认，不能更改！');{/if}"/><!--{/if}--></td>
		
      </tr>
	  </form>
	  <form method="post" action="{url app=sample&act=edit&id=$smarty.get.id}" id="update_sample_form">
      <tr>
        <th>{$lang.factory_back_date}：</th>
        <td class="tab-align-l"><!--{if !$sample.factory_back_date || $sample.status == 0}--><input type="text" name="factory_back_date" id="factory_back_date" class="input-1" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$sample.factory_back_date|date:Y-m-d}" /><!--{else}-->{$sample.factory_back_date|date:Y-m-d}<!--{/if}--></td>
        <th>{$lang.factory_price}：</th>
        <td class="tab-align-l" colspan="2"><input type="text" name="factory_price" value="{$sample.factory_price}" class="input-1" /></td>
      </tr>
      <tr>
        <th>{$lang.send_sample_date}：</th>
        <td class="tab-align-l" colspan="4"><!--{if !$sample.send_sample_date || $sample.status == 0}--><input type="text" name="send_sample_date" id="send_sample_date" class="input-1" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$sample.send_sample_date|date:Y-m-d}" /><!--{else}-->{$sample.send_sample_date|date:Y-m-d}<!--{/if}--></td>
      </tr>
      <tr>
        <th>{$lang.description}：</th>
        <td class="tab-align-l" colspan="3"><textarea name="description" cols="81" rows="5">{$sample.description|escape}</textarea></td>
        <td align="left" valign="middle" align="center"><input type="submit" name="update_sample" class="btn-2" value="{$lang.update}" onClick="{if $sample.confirm_date}alert('{$lang.sample_confirmed_can_not_update}');return false;{else}{if !$sample.factory_back_date || !$sample.send_sample_date}return confirm_update();{/if}{/if}" /></td>
      </tr>
	  </form>
      <tr>
        <th>{$lang.enclosure}：</th>
        <td class="tab-align-l" id="factory_files">
		<!--{foreach from=$sample.factory_files item=file}-->
		<a href="download.php?id={$file.file_id}">{$file.file_name}</a><a class="pic_del" href="{url app=comupload&act=delete&id=$file.file_id}" onClick="return confirm('{$lang.confirm_del_file}')" title="{$lang.delete}">&nbsp;</a><!--{if !$smarty.foreach.last}--><br /><!--{/if}-->
		<!--{/foreach}-->
		</td>
        <td colspan="3" class="tab-align-l"><input type="button" class="btn-3" value="{$lang.upload_enclosure}" onClick="upload_docs({$belongs_factory}, {$sample.sample_id});" /></td>
      </tr>
    </table>
  </div>
  <br />
  <div style="text-align:center;">
  <input type="button" class="btn-4" value="{$lang.confirm_sample}" onClick="{if !$sample.confirm_date}if(confirm('{$lang.do_confirm_sample}')){location.href='{url app=sample&act=confirm_sample&id=$sample.sample_id}'}{else}alert('{$lang.sample_confirmed}');{/if}" />&nbsp;&nbsp;<input type="button" class="btn-4" value="返回" onClick="history.back();" />
  </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>